//
//  GHsearchTf.m
//  12-guhu_weibo
//
//  Created by GHapple on 15-2-1.
//  Copyright (c) 2015年 itcast. All rights reserved.
//

#import "GHsearchTf.h"

@implementation GHsearchTf

- (id)initWithCoder:(NSCoder *)aDecoder{
    if (self = [super initWithCoder:aDecoder]) {
        [self setting];
    }
    return  self;
}
- (instancetype)initWithFrame:(CGRect)frame{

    if (self = [super initWithFrame:frame]) {
        [self setting];
    }
    return self;
}


- (void)setting{

//     设置一次性的操
      //  titleView 设置X和Y是无效的
    // UITextField要设置边框的样式(默认没有边框)
    self.borderStyle = UITextBorderStyleRoundedRect;
   self.placeholder = @"请输入你想搜索的内容";
    self.clearButtonMode = UITextFieldViewModeAlways;
    
    // 添加放大镜  通过UIImageView的initWithImage创建出来的可以不设置frame默认是image的宽高
    
    UIImageView *icon = [[UIImageView alloc]initWithImage:[UIImage imageNamed:@"searchbar_searchlist_search_icon"]];
   
    self.leftView = icon;
    // 设置leftView的样式
    self.leftViewMode = UITextFieldViewModeAlways;

}
- (void)setIconName:(NSString *)iconName{

    _iconName  = iconName;
    UIImageView *icon = [[UIImageView alloc]initWithImage:[UIImage imageNamed:iconName]];
    icon.width = 30;
    icon.contentMode = UIViewContentModeCenter;
    self.leftView = icon;
}
@end
